home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bc_ti.zip / TI639.ASC < prev    next >
Text File  |  1992-02-25  |  815b  |  67 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.   PRODUCT  :  C++                                    NUMBER  :  639
  9.   VERSION  :  All
  10.        OS  :  PC DOS
  11.      DATE  :  February 25, 1992                        PAGE  :  1/1
  12.  
  13.     TITLE  :  Creating a Pointer to Member Function
  14.  
  15.  
  16.  
  17.  
  18.   #include <stdio.h>
  19.  
  20.   class testclass {
  21.     public:
  22.       void test(int x) { printf("-> %d <-", x); }
  23.   };
  24.  
  25.   void main(void)
  26.   {
  27.     testclass xxx;
  28.     void (testclass::*p_func) (int); // p_func is type pointer to member
  29.                                      // function accepting an int and
  30.                                      // returning void
  31.  
  32.     p_func = testclass::test;        // assign p_func the address of test
  33.     (xxx.*p_func) (3);               // call test
  34.   }
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.